package com.example.jobback.controller.manager;

import com.example.jobback.req.manager.employee.ManagerEmployeeCreatedReq;
import com.example.jobback.req.recruiter.employee.create.EmployeeCreatedReq;
import com.example.jobback.resp.manager.employee.page.manager.GetPageManagersResp;
import com.example.jobback.resp.manager.employee.page.recruiter.MCrossGetPageRecruitersResp;
import com.example.jobback.resp.manager.employee.page.seeker.MCrossGetPageSeekersResp;
import com.example.jobback.resp.recruiter.common.page.RCrossGetPageRecruitersResp;
import com.example.jobback.result.Result;
import com.example.jobback.service.manager.ManagerEmployeeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ManagerEmployeeController
 * @Description:管理员-员工管理控制器
 * @Author: lhb
 * @Date: 2025/6/30
 */
@RestController
@RequestMapping("/manager/employee")
@Tag(name = "管理员-员工管理控制器",description = "管理员员工管理服务的相关接口,")
public class ManagerEmployeeController {

    private final ManagerEmployeeService managerEmployeeService;

    public ManagerEmployeeController(ManagerEmployeeService managerEmployeeService) {
        this.managerEmployeeService = managerEmployeeService;
    }


    @Operation(summary = "增设员工",description = "增设员工，super才有权限")
    @ApiResponse(description = "返回token，前端更新token")
    @PostMapping("/createEmployee")
    public Result<Object> createEmployee(@Validated
                                             @RequestBody
                                         ManagerEmployeeCreatedReq req) {
        return managerEmployeeService.createEmployee(req);
    }

    @Operation(summary = "删除管理员",description = "无")
    @ApiResponse(description = "返回token")
    @DeleteMapping("/deleteManager")
    public Result<Object> deleteManager(@Parameter(description = "用户userId", required = true)
                                                   @RequestParam Long deleteUserId){
        return managerEmployeeService.deleteManager(deleteUserId);
    }

    @Operation(summary = "获取管理员列表",description = "无")
    @ApiResponse(description = "返回token")
    @GetMapping("/getManagers")
    public Result<GetPageManagersResp> getManagers(@Parameter(description = "页码", required = true)@RequestParam int page,
                                                   @Parameter(description = "每页的数量", required = true)@RequestParam int size,
                                                   @Parameter(description = "搜索内容", required = true)@RequestParam String content){
        return managerEmployeeService.getManagers(page,size,content);
    }


    @Operation(summary = "获取求职者列表",description = "跨服务调用，调用方")
    @ApiResponse(description = "返回token")
    @GetMapping("/getSeekers")
    public Result<MCrossGetPageSeekersResp> getSeekers(@Parameter(description = "页码", required = true)@RequestParam int page,
                                                       @Parameter(description = "每页的数量", required = true)@RequestParam int size,
                                                       @Parameter(description = "搜索内容", required = true)@RequestParam String content){
        return managerEmployeeService.getSeekers(page,size,content);
    }

    @Operation(summary = "获取招聘者列表",description = "跨服务调用，调用方")
    @ApiResponse(description = "无")
    @GetMapping("/getRecruiters")
    public Result<MCrossGetPageRecruitersResp> getRecruiters(@Parameter(description = "页码", required = true)@RequestParam int page,
                                                             @Parameter(description = "每页的数量", required = true)@RequestParam int size,
                                                             @Parameter(description = "搜索内容", required = true)@RequestParam String content){
        return managerEmployeeService.getRecruiters(page,size,content);
    }

}
